package cn.seapon.talker.adapters;

import java.util.ArrayList;

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.GridView;
/**
 * ViewPage数据适配器
 * @author daobo.yuan
 *
 */
public class ExpressionPagerAdapter extends PagerAdapter {
	
	private ArrayList<GridView> gridViews;
	
	public ExpressionPagerAdapter(ArrayList<GridView> gridViews) {
		this.gridViews = gridViews;
	}
	
	public void setGrids(ArrayList<GridView> gridViews) {
		this.gridViews = gridViews;
	}

	@Override
	public int getCount() {
		return gridViews.size();
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		return arg0 == arg1;
	}

	@Override
	public void destroyItem(View container, int position, Object object) {
		((ViewPager) container).removeView(gridViews.get(position));
	}

	@Override
	public Object instantiateItem(View container, int position) {
		((ViewPager) container).addView(gridViews.get(position));
		return gridViews.get(position);
	}
}
